package com.example.base_mvvm.entity;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;

public class DisLikeEntity {


    private int code;
    private String message;
    private String data;

    public static DisLikeEntity objectFromData(String str) {

        return new Gson().fromJson(str, DisLikeEntity.class);
    }

    public static DisLikeEntity objectFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);

            return new Gson().fromJson(jsonObject.getString(str), DisLikeEntity.class);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    public static List<DisLikeEntity> arrayDisLikeEntityFromData(String str) {

        Type listType = new TypeToken<ArrayList<DisLikeEntity>>() {
        }.getType();

        return new Gson().fromJson(str, listType);
    }

    public static List<DisLikeEntity> arrayDisLikeEntityFromData(String str, String key) {

        try {
            JSONObject jsonObject = new JSONObject(str);
            Type listType = new TypeToken<ArrayList<DisLikeEntity>>() {
            }.getType();

            return new Gson().fromJson(jsonObject.getString(str), listType);

        } catch (JSONException e) {
            e.printStackTrace();
        }

        return new ArrayList();


    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getData() {
        return data;
    }

    public void setData(String data) {
        this.data = data;
    }
}
